#!/bin/bash

if [ $# != 2 ] || ([ $1 != "vars" ] && [ $1 != "test" ])
then
    echo "Usage: set-odbc-password vars|test ODBC_PASSWORD"
    exit 1
fi

TOOLS=`dirname $0`
if [ `uname` = "Darwin" ]; then
    BASE=$(cd "$TOOLS/.."; pwd -P)
    SED=gsed
else
    BASE=`readlink -f $TOOLS/..`
    SED=sed
fi

if [ $1 == "vars" ]
then
    CFGS="$BASE/rel/vars.config $BASE/rel/reltool_vars/*.config"
else
    CFGS="$BASE/test/ejabberd_tests/test.config"
fi
$SED -e "s/%ODBC_PASSWORD%/$2/" -i -- $CFGS
